<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<style type="text/css">
			body{background-color: #fff;}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">忘记密码</h1>
		</header>
		<div class="mui-content mui-content-form">
			<div id="boxMobile">
				<form class="mui-input-group mui-margin-top">
					<div class="mui-input-row authCode">
						<input id='MobileNo' type="tel" oninput="if(value.length>13)value=value.slice(0,13)" onkeyup="formatMobile(this)" class="mui-input-clear mui-input" placeholder="您的手机号">
							<button type="button" id="btnSendAuthCode" class="mui-btn-mini" data-type="找回密码" data-check="0">发送验证码</button>
					</div>				
				</form>
				<form class="mui-input-group mui-margin-top">
					<div class="mui-input-row">
						<input id='AuthCode' type="number" class="mui-input-clear mui-input" placeholder="请输入短信验证码">
					</div>
				</form>
				<div class="mui-content-padded pt-10">
					<button id='btnNext' class="mui-btn mui-btn-block mui-btn-danger">下一步</button>
				</div>
			</div>
			<div id="boxSetPassword" style="display: none;">
				<form class="mui-input-group mui-margin-top">
					<div class="mui-input-row">
						<input id='Password' type="password" class="mui-input-clear mui-input" placeholder="请输入新登录密码">
					</div>				
				</form>
				<div class="mui-content-padded pt-10">
					<button id='submit' class="mui-btn mui-btn-block mui-btn-danger">确定</button>
				</div>
			</div>
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/app.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			mui.init();
			 
			var $boxMobile = document.getElementById("boxMobile");
			var $boxPassword = document.getElementById("boxSetPassword");
			
			var $MobileNo = document.getElementById("MobileNo");
			var $AuthCode = document.getElementById("AuthCode");
			var $Password = document.getElementById("Password");					
						
			document.getElementById("btnNext").addEventListener('tap', function () {
				var mobile = $MobileNo.value.replace(/\s/g,"");
				var authCode = $AuthCode.value;
				
				if(!checkMobile(mobile)){
					return;
				}				
				if(authCode == ""){
					mui.toast("请输入验证码");
					return;
				}
				
				$boxMobile.style.display = "none";
				$boxPassword.style.display = "block";
			});
			
			document.getElementById("submit").addEventListener('tap', function () {
				var mobile = $MobileNo.value.replace(/\s/g,"");
				var authCode = $AuthCode.value;
				var password = $Password.value;
				 
				if(password == ""){
					mui.toast("请输入登录密码");
					return;
				}
				
				mui.showLoading();
				var wv = plus.webview.currentWebview();
				app.post("SetNewPassword", {Mobile:mobile, Password:password, AuthCode:authCode}, function (data) {
					if(data.isSuccess) {
						mui.toast("密码设置成功");
						app.openLogin();
						setTimeout(function () {
							wv.close();	
						},500);
					} else {
						mui.toast(data.message);
					}
				})
			});
			
		</script> 
	</body>

</html>